package domain.entities;

import javax.persistence.*;
import java.util.Date;

import static javax.persistence.GenerationType.IDENTITY;

/**
 * Created with IntelliJ IDEA.
 * User: scamisay
 * Date: 11/28/12
 * Time: 11:12 AM
 * To change this template use File | Settings | File Templates.
 */
@Entity
public class EquipmentSiteProtocoloCompromisoPais {
    private Integer id;
    private Equipmentcertification equipment;
    private Centro site;
    private ProtocoloCompromisopais pcp;
    private boolean selected;

    private Date from;
    private Date until;

    public EquipmentSiteProtocoloCompromisoPais(){}

    public EquipmentSiteProtocoloCompromisoPais(
            Equipmentcertification equipment,
            Centro site,
            ProtocoloCompromisopais pcp,
            boolean selected
    ){
        this.equipment = equipment;
        this.site = site;
        this.pcp = pcp;
        this.selected = selected;
    }

    @Id
    @GeneratedValue(strategy = IDENTITY)
    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    @ManyToOne( fetch = FetchType.EAGER)
    public Equipmentcertification getEquipment() {
        return equipment;
    }

    public void setEquipment(Equipmentcertification equipment) {
        this.equipment = equipment;
    }

    @ManyToOne(fetch = FetchType.EAGER)
    public Centro getSite() {
        return site;
    }

    public void setSite(Centro site) {
        this.site = site;
    }

    @ManyToOne(fetch = FetchType.EAGER)
    public ProtocoloCompromisopais getPcp() {
        return pcp;
    }

    public void setPcp(ProtocoloCompromisopais pcp) {
        this.pcp = pcp;
    }

    public boolean isSelected() {
        return selected;
    }

    public void setSelected(boolean selected) {
        this.selected = selected;
    }

    @Temporal(TemporalType.DATE)
    @Column(name = "dateFrom", length = 10)
    public Date getFrom() {
        return from;
    }

    public void setFrom(Date from) {
        this.from = from;
    }

    @Temporal(TemporalType.DATE)
    @Column(name = "until", length = 10)
    public Date getUntil() {
        return until;
    }

    public void setUntil(Date until) {
        this.until = until;
    }

    @Transient
    public boolean isNew(){
        return this.id == null;
    }

}
